package org.sxm.cloud.fegin;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import feign.codec.Decoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description
 * @Author xmSheng
 * @Date 2024/1/22
 */
@Configuration
public class FeginConfiguration implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate requestTemplate) {
        //设置内部服务,如果Fegin内部调用，则接口返回不做统一返回参数封装
        requestTemplate.header(ReqeustConstants.INNER_SERVICE, "1");
    }

    /**
     * 自定义OpenFegin解码器
     * @return
     */
    @Bean
    public Decoder feginResponseDecoder(){
        return new FeginResponseDecoder();
    }
}
